package th.co.exat.model;

import com.channgam.dbmlib.sql.MySQLJDBC;
import com.channgam.dbmlib.sql.iDataAdapter;
import java.util.ArrayList;
import java.util.List;
import th.co.exat.model.container.LineContainer;
import th.co.exat.uap.config.Config;

public class Line {

    private static iDataAdapter i;

    public static List<LineContainer> getDataList() throws Exception {
        List<LineContainer> list = new ArrayList<LineContainer>();
        i = new MySQLJDBC(Config.getMySqlHost(),
                Config.getMySqlUsername(),
                Config.getMySqlPassword(),
                Config.getMySqlDbname());
        i.connect();
        String sql = "SELECT * "
                + "FROM uap_mst_line "
                + "WHERE 1 ";
        i.query(sql);

        while (i.resultNext()) {
            LineContainer l = new LineContainer();
            l.setLineId(i.result().getString("line_id"));
            l.setLineName(i.result().getString("line_name"));
            list.add(l);
        }

        i.close();
        return list;
    }
}
